package com.foreknow.demo3;

/**
 * 数组的排序
 *     冒泡排序
 *         已知数组
 *             [15 7 22 14 8 16 10]
 */
public class ArraySort {
    public static void main(String[] args) {
        //初始化数组
        int[] array = {15,7,22,14,8,16,10};
        for (int i = 1;i<array.length;i++){
            for (int j = 0;j<array.length-i;j++){
                if (array[j] > array[j+1]){
                    int temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                }
            }
        }
        for (int i = 0; i<array.length;i++){
            System.out.println(array[i]);
        }
    }

}
